package newKe;

import java.util.HashMap;
import java.util.Map;

public class NC61 {
    /**
     *
     * @param numbers int整型一维数组
     * @param target int整型
     * @return int整型一维数组
     */
    public int[] twoSum (int[] numbers, int target) {
        // write code here
        Map<Integer,Integer> map = new HashMap<>();

        int len = numbers.length;
        for(int i=0;i<len;i++){
            if(map.containsKey(target-numbers[i])){
                return new int[]{map.get(target-numbers[i]),i+1};
            }else {
                map.put(numbers[i],i+1);
            }
        }

        return null;
    }
}
